package com.heima.article.service.impl;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.heima.article.mapper.ApAuthorMapper;
import com.heima.article.service.IApAuthorService;
import com.heima.model.article.pojos.ApAuthor;
import com.heima.model.common.dtos.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 * APP文章作者信息表 服务实现类
 * </p>
 *
 * @author zqc
 * @since 2024-08-22
 */
@Service
public class ApAuthorServiceImpl extends ServiceImpl<ApAuthorMapper, ApAuthor> implements IApAuthorService {
    @Autowired
    private ApAuthorMapper apAuthorMapper;

    @Override
    public ResponseResult add(ApAuthor apAuthor) {
        apAuthorMapper.insert(apAuthor);
        LambdaQueryWrapper<ApAuthor> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(ApAuthor::getUserId, apAuthor.getUserId());
        ApAuthor author = apAuthorMapper.selectOne(wrapper);
        return ResponseResult.okResult(author.getId());
    }
}
